package org.test.controller;

import org.test.controller.frontend.MainPageController;
import org.test.controller.superadmin.HeadLineOperationController;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created by Hy on 2021/7/24.
 */
@WebServlet("/")
public class DispacherServlet extends HttpServlet{
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp)  {
        System.out.println("request path is:"+req.getServletPath());
        System.out.println("request method is:"+req.getMethod());
        if(req.getServletPath()== "/frontend/getmainpageinfo" && req.getMethod() == "GET"){
            new MainPageController().getMainPageInfo(req,resp);
        }else if(req.getServletPath()== "/superadmin/addheadline" && req.getMethod() == "POST"){
            new HeadLineOperationController().add(req,resp);
        }
    }
}
